﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="users.aspx.cs" Inherits="EnmineKaitlin.admin.users" MasterPageFile="~/MasterPage/AdminDefault.Master" %>
<%@ Register Assembly="EnmineKaitlin" Namespace="EnmineKaitlin.Common" TagPrefix="Pagging" %>
<asp:Content ID="ctnuser" runat="server" ContentPlaceHolderID="cphContent">
    <div class="form list">
        <h2><span class="icon"><img src="../images/admin/Play.png"></span>Người dùng</h2>
        <div class="content">
            <div class="left add-user">
                <asp:Panel ID="pnlAddUser" runat="server">
                <h3>Thêm người dùng</h3>
                <table border="0">
                    <tr>
                        <td align="right">Tên đăng nhập:</td>
                        <td><asp:TextBox ID="txtUserName" Width="180" runat="server" CssClass="txt required"></asp:TextBox></td>
                    </tr>
                    <tr><td align="right">Mật khẩu:</td><td><asp:TextBox ID="txtPassword" Width="180" TextMode="Password" runat="server" CssClass="txt required password"></asp:TextBox></td></tr>
                    <tr><td align="right">Xác nhận mật khẩu:</td><td><asp:TextBox ID="txtPasswordConfirm" Width="180" runat="server" TextMode="Password" CssClass="txt required password_again"></asp:TextBox></td></tr>
                    <tr><td align="right">Họ và tên:</td><td><asp:TextBox ID="txtFullName" Width="180" runat="server" CssClass="txt required"></asp:TextBox></td></tr>
                    <tr><td align="right">Email:</td><td><asp:TextBox ID="txtEmail" Width="180" runat="server" CssClass="txt email"></asp:TextBox></td></tr>
                    <tr><td align="right">Số di động:</td><td><asp:TextBox ID="txtPhone" Width="180" runat="server" CssClass="txt"></asp:TextBox></td></tr>
                    <tr><td align="right">Số máy bàn:</td><td><asp:TextBox ID="txtTel" Width="180" runat="server" CssClass="txt"></asp:TextBox></td></tr>
                    <tr><td align="right">Ngày sinh:</td><td><asp:TextBox ID="txtBirthday" Width="180" runat="server" CssClass="txt datepicker required"></asp:TextBox></td></tr>
                    <tr><td align="right">Giới tính:</td><td><asp:DropDownList ID="ddlGender" runat="server" Width="185">
                        <asp:ListItem Text="Nam" Value="male"></asp:ListItem>
                        <asp:ListItem Text="Nữ" Value="female"></asp:ListItem>
                        <asp:ListItem Text="Khác" Value="other"></asp:ListItem>
                    </asp:DropDownList></td></tr>
                    <tr><td align="right">Địa chỉ:</td><td><asp:TextBox ID="txtAddress" Width="180" runat="server" CssClass="txt"></asp:TextBox></td></tr>
                    <tr><td align="right">Vị trí:</td><td><asp:TextBox ID="txtPosition" Width="180" runat="server" CssClass="txt"></asp:TextBox></td></tr>
                    <tr><td align="right">Trạng thái:</td><td><asp:DropDownList ID="ddlStatus" Width="185" runat="server">
                        <asp:ListItem Text="Hoạt động" Value="active"></asp:ListItem>
                        <asp:ListItem Text="Khóa" Value="lock"></asp:ListItem>
                    </asp:DropDownList></td></tr>
                    <tr><td align="right">Nhóm người dùng:</td><td><asp:DropDownList ID="ddlUserGroup" Width="185" DataTextField="Name" DataValueField="GroupID" runat="server"></asp:DropDownList></td></tr>
                    <tr><td></td><td><asp:Button ID="btnAddUser" runat="server" Text="Thêm người dùng" CssClass="btn right btnUpdateUser" OnClick="btnAddUser_Click" /></td></tr>                                                                
                </table>
                </asp:Panel>
                <asp:Panel ID="pnlDetailUser" runat="server" Visible="false">
                    <h3>Cập nhật người dùng</h3>
                    <asp:Repeater ID="rptDetailUser" runat="server" OnItemCommand="rptDetailUser_Update">
                        <HeaderTemplate><table border="0"></HeaderTemplate>
                        <ItemTemplate>                            
                                <tr>
                                    <td align="right">Tên đăng nhập:</td>
                                    <td><asp:TextBox ID="txtUserName" Width="180" runat="server" Enabled="false" Text='<%#Eval("UserName") %>' CssClass="txt required"></asp:TextBox></td>
                                </tr>
                                <tr><td align="right">Mật khẩu:</td><td><asp:TextBox ID="txtPassword" Width="180" TextMode="Password" runat="server" CssClass="txt password"></asp:TextBox></td></tr>
                                <tr><td align="right">Xác nhận mật khẩu:</td><td><asp:TextBox ID="txtPasswordConfirm" Width="180" runat="server" TextMode="Password" CssClass="txt password_again"></asp:TextBox></td></tr>
                                <tr><td align="right">Họ và tên:</td><td><asp:TextBox ID="txtFullName" Width="180" runat="server" Text='<%#Eval("FullName") %>' CssClass="txt required"></asp:TextBox></td></tr>
                                <tr><td align="right">Email:</td><td><asp:TextBox ID="txtEmail" Width="180" runat="server" CssClass="txt email" Text='<%#Eval("Email") %>'></asp:TextBox></td></tr>
                                <tr><td align="right">Số di động:</td><td><asp:TextBox ID="txtPhone" Width="180" runat="server" CssClass="txt" Text='<%#Eval("PhoneNumber") %>'></asp:TextBox></td></tr>
                                <tr><td align="right">Số máy bàn:</td><td><asp:TextBox ID="txtTel" Width="180" runat="server" CssClass="txt" Text='<%#Eval("Tel") %>'></asp:TextBox></td></tr>
                                <tr><td align="right">Ngày sinh:</td><td><asp:TextBox ID="txtBirthday" Width="180" runat="server" CssClass="txt datepicker required" Text='<%#DisplayDateTime(Eval("BirthDay").ToString()) %>'></asp:TextBox></td></tr>
                                <tr><td align="right">Giới tính:</td><td><asp:DropDownList ID="ddlGender" runat="server" Width="185" SelectedValue='<%#Eval("Gender") %>'>
                                    <asp:ListItem Text="Nam" Value="male"></asp:ListItem>
                                    <asp:ListItem Text="Nữ" Value="female"></asp:ListItem>
                                    <asp:ListItem Text="Khác" Value="other"></asp:ListItem>
                                </asp:DropDownList></td></tr>
                                <tr><td align="right">Địa chỉ:</td><td><asp:TextBox ID="txtAddress" Width="180" runat="server" CssClass="txt" Text='<%#Eval("Address") %>'></asp:TextBox></td></tr>
                                <tr><td align="right">Vị trí:</td><td><asp:TextBox ID="txtPosition" Width="180" runat="server" CssClass="txt" Text='<%#Eval("Position") %>'></asp:TextBox></td></tr>
                                <tr><td align="right">Trạng thái:</td><td><asp:DropDownList ID="ddlStatus" Width="185" runat="server" SelectedValue='<%#Eval("Status") %>'>
                                    <asp:ListItem Text="Hoạt động" Value="active"></asp:ListItem>
                                    <asp:ListItem Text="Khóa" Value="lock"></asp:ListItem>
                                </asp:DropDownList></td></tr>
                                <tr><td align="right">Nhóm người dùng:</td><td><asp:DropDownList ID="ddlUserGroup" DataSource='<%#BindGroup() %>' Width="185" DataTextField="Name" DataValueField="GroupID" SelectedValue='<%#Eval("IDGroup") %>' runat="server"></asp:DropDownList></td></tr>
                                <tr><td></td><td><asp:Button ID="btnUpdateUser" runat="server" Text="Cập nhật" CssClass="btn right btnUpdateUser" CommandName="Update" CommandArgument='<%#Eval("UserID") %>' /></td></tr>                                                                                            
                        </ItemTemplate>
                        <FooterTemplate></table></FooterTemplate>
                    </asp:Repeater>
                </asp:Panel>
            </div>
            <div class="list-cat-right">
                <asp:Label ID="lblNotice" runat="server" CssClass="error"></asp:Label>
                <div class="filter">                
                    <div class="filter-item left">
                        <p>Từ khóa:&nbsp;<asp:TextBox ID="txtKeyWord" Value="Nhập từ khóa" runat="server" Width="100" CssClass="txt txtsearch"></asp:TextBox></p>
                    </div>                    
                    <div class="filter-item left">
                        <p>Nhóm người dùng:&nbsp;<asp:DropDownList ID="ddlUserGroupFilter" runat="server" DataValueField="GroupID" DataTextField="Name"></asp:DropDownList></p>
                    </div>                    
                    <div class="filter-item left">
                        Trạng thái:&nbsp;
                        <asp:DropDownList ID="ddlStatusFilter" runat="server">
                            <asp:ListItem Text="Tất cả" Value=""></asp:ListItem>
                            <asp:ListItem Text="Hoạt động" Value="active"></asp:ListItem>
                            <asp:ListItem Text="Khóa" Value="lock"></asp:ListItem>
                        </asp:DropDownList>
                        &nbsp;&nbsp;&nbsp;<asp:LinkButton ID="btnFilter" Text="Lọc" runat="server" CssClass="link-btn" CommandName="Filter" OnCommand="btnFilter_Command"></asp:LinkButton>
                    </div>                              
                </div>                    
                <div class="function">
                    <asp:DropDownList ID="ddlFunctionTop" runat="server" CssClass="select">
                        <asp:ListItem Selected="True" Text="Chọn thao tác" Value=""></asp:ListItem>
                        <asp:ListItem Text="Xóa" Value="delete"></asp:ListItem>
                        <asp:ListItem Text="Bỏ khóa" Value="unlock"></asp:ListItem>
                        <asp:ListItem Text="Khóa" Value="lock"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:LinkButton ID="lbtFunction" runat="server" Text="Thực hiện" CssClass="link-btn" CommandName="BunkFunction" OnCommand="lbtFunction_Click" CommandArgument="TopFunction"></asp:LinkButton>	            
                </div>
                <asp:GridView ID="grvUser" runat="server" AutoGenerateColumns="false" 
                    DataKeyNames="UserName" Width="100%" 
                    CssClass="tbl-list" AlternatingRowStyle-BackColor="AntiqueWhite" OnRowDataBound="grvUser_RowDataBound" 
                    OnRowCommand="grvUser_RowCommand" onrowdeleting="grvUser_RowDeleting">
                    <Columns>
                        <asp:TemplateField HeaderText="">
                            <ItemTemplate><asp:CheckBox ID="CheckBox1" runat="server" CssClass="cbxItem" /></ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="STT" >
                            <ItemTemplate><%#Container.DataItemIndex+1 %></ItemTemplate>
                        </asp:TemplateField>    
                        <asp:BoundField HeaderText="Họ tên" DataField="FullName" />                    
                        <asp:BoundField HeaderText="Tên đăng nhập" DataField="UserName" />
                        <asp:TemplateField HeaderText="Nhóm người dùng">
                            <ItemTemplate>
                                <asp:DropDownList ID="ddlGroup" DataTextField="Name" DataValueField="GroupID" runat="server" Enabled="false" DataSource='<%#BindGroup() %>' SelectedValue='<%#Eval("IDGroup") %>'></asp:DropDownList>
                            </ItemTemplate>                            
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Thao tác" ItemStyle-Width="60">
                            <ItemTemplate>
                                <a href='/admin/users.aspx?uid=<%#Eval("UserID") %>' class="btnEdit">Sửa</a>
                                <asp:LinkButton ID="lbtDelete" runat="server" CssClass="btnDelete" Text="Xóa" CommandName="delete" CommandArgument='<%#Eval("UserName") %>'></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>  
                <div class="pagenav">                    
                    <Pagging:PaggingControl runat="server" ID="ctlPagging" Mode="Url" PageSize="20"
                    PreviousClause="<img src='../images/Back.png'/>" NextClause="<img src='../images/Forward.png'/>" />
                </div>              
            </div>
        </div>
    </div>
</asp:Content>
